import { isObject, isString } from '@/utils/is';


export interface fieldObj {
  stageId: string;
  groupId: string;
  id: string;
}

export function handleField(stageId: number,data: string | { groupId: number; id: number }): string | fieldObj {
  /** field 组装 拼接 阶段id_组id_表单itemId */
  if (isObject(data) && data?.groupId && data?.id) {
    return `${stageId}_${data.groupId}_${data.id}`;
  }
  /** field 拆解 */
  if (isString(data)) {
    const ids = data.split('_');
    return {
      stageId: ids[0],
      groupId: ids[1],
      id: ids[2],
    };
  }
  return '';
}